#!/usr/bin/env python
# -*- coding: UTF-8 -*-

# key为正常的报警码 value为异常的报警码
__RobotError = {0X0611: 0x0610, 0X0613: 0x0612, 0X0615: 0x0614, 0X0617: 0x0616}

def try_catch(func):
    def wrapper(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except Exception as e:
            print('Caught an exception:', e)
    return wrapper

def getErrorCode(code):
    """_summary_
        报警恢复的错误码 转成 报警异常的错误码
    Args:
        code (_type_): _description_

    Returns:
        _type_: _description_
    """
    if code in __RobotError:
        return __RobotError[code]
    return code

def ignoreCode(code):
    """_summary_
    忽略不需要处理的错误码
    Args:
        code (_type_): _description_

    Returns:
        _type_: _description_
    """
    if code in __RobotError:
        return True
    return False